import requests
import json
'''
    更改 ip |x_dog_token  |device_id
'''
# ip = "http://127.0.0.1:7998"
# ip = "http://52.83.100.136:7898"
# ip = "http://test-mars.dev-bp.atcloudbox.com"
# ip = "http://poseidon-service.atcloudbox.com"

# bytepower
# ip = "https://60q8ur7nq7.server.bytepowerapp.cn"
# ip = "https://mars-service.atcloudbox.com/"
x_dog_token = "vrYPjGoAaYvUNlRBnYEStdoXdCMSNkaJ"
ip = 'http://test-mars.dev-bp.atcloudbox.com'
# ip = 'http://test-poseidon.dev-bp.atcloudbox.com'
# ip = 'http://test-ares.dev-bp.atcloudbox.com'
# vivo 863542038347750
# 华为 866676049576853

# X-TVU-Code 代表高低价值，0代表低价值，1代表高价值
headers = {'X-Platform': 'Android', 'Content-Type': 'application/json', 'charset':'utf-8',
    "X-Dog-Token": x_dog_token, "X-Version-Code": "1160", "X-TVU-Code": "0", "User-Agent":"okhttp/3.12.0", "Accept-Encoding": "gzip","X-Config-Version":"10041"}




# curl -H "Content-Type:application/json" -X POST -d '{"wechat_name":"葫芦&狐狸"}' http://test-mars.dev-bp.atcloudbox.com/delete_user



def get_user_info():
    r = requests.get(ip+'/bp/server/user/UUBFI6XDQCFEP')
    print(r.text)

# get_user_info()


def login():
    r = requests.post(ip+'/user/login', json={"login_type": 0, "login_info": {"device_id": "$$$$%%%%%1234"}})
    print(r.text)
    x_dog_token = r.json()["data"]["token"]
    return x_dog_token
    # print(x_dog_token)
def wechat_list():  #获取随机微信名和金额
    r = requests.get(ip+'/invite/v2/wechat_list', headers=headers)
    print(r.status_code)
    print(r.text)
def invitor_info(): #获取邀请人信息
    r = requests.get(ip+'/invite/v2/invitor_info', headers=headers)
    print(r.status_code)
    print(r.text)
def invitor_friends_info(): #好友列表总览
    r = requests.get(ip+'/invite/v2/invitor_friends_info', headers=headers)
    print(r.status_code)
    print(r.text)
def invitor_friends_list(): #获取好友列表
    r = requests.get(ip+'/invite/v2/invitor_friends_list?num_per_page=100&page_num=1&is_active=True', headers=headers)
    print(r.status_code)
    print(r.text)
def ad_video():  #激励视频上报
    r = requests.post(ip+'/report/ad_video', headers=headers, json={"vendor_id": "kk123131", "ecpm": 0.689999997615814})
    print(r.status_code)
    print(r.text)

for i in range(10):
    ad_video()
    print('end...')


def invite_profit(): #上报是否参与邀请收益活动
    r = requests.post(ip+'/report/invite_profit', headers=headers, json={"invite_profit_switch": True})
    print(r.status_code)
    print(r.text)
def game_status(): #新增信息
    r = requests.get(ip+'/game_status', headers=headers)
    print(r.status_code)
    print(r.text)
def withdraw_config(): #
    r = requests.get(ip+'/wallet/config', headers=headers)
    print(r.status_code)
    print(r.text)
def report_invitee():
    r = requests.post(ip+'/invite/v2/report/invitee', headers=headers, json={
        "from_invite_code": "87398521"
    })
    print(r.status_code)
    print(r.text)

def linked_to():
    r = requests.post(ip+'/invite/v2/linkto/51635819')
    print(r.status_code)
    print(r.text)


def get_config():
    r = requests.get(ip+'/config', headers=headers)
    print(r.status_code)
    print(r.text)
#重置新用户
def reset_deviceid():
    r = requests.post(ip+'/game/reset_device_id', headers=headers)
    print(r.status_code)
    print(r.text)
    print(r)


# reset_deviceid()
#


def bind_wechat():
    r = requests.post(ip+'/user/bind', headers=headers, json={"bind_type":1, "bind_info": {"wechat_code":"061iUFQa2plqXJ0pyGRa2rKNQa2iUFQSG"}})
    print(r.status_code)
    print(r.text)

#解绑微信
def unbind_bytepower_wechat():
    user_id = 'UUA5UR5DREWCK'
    platform = 'wechat'
    url = 'https://bp-gateway-stage.appcloudbox.net/user/{0}/{1}/{2}'.format(user_id,)
    print(url)
    headers = {
        "Accept": "application/vnd.bytepower.v1+json",
        "X-BytePower-Application-Id": "APPZ2RRFLBOQZCJI",
        "X-BytePower-Auth-Token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1ODE5OTcyNTYxODAsImtleV9uYW1lIjoiZTZhYjIzZTJhZmE5NGRkYiJ9.5VlAAFzNRem7F8b2e5uPXJVE-E9FIU1vsSG1c-TAWx4"
    }
def profile(): #获取邀请URL
    r = requests.get(ip+'/user/profile', headers=headers)
    print(r.status_code)
    print(r.text)
def game_start():
    r = requests.post(ip+'/game/start', headers=headers)
    print(r.status_code)
    print(r.text)
    return r.json()["data"]["extra"]["challengedCheckpoint"]
def game_end2(challengedCheckpoint):
    r = requests.post(ip+'/game/end2', headers=headers, json={"passed_checkpoint":challengedCheckpoint })
    print(r.status_code)
    print(r.text)
def wallet_history():
    r = requests.get(ip+'/wallet/history', headers=headers)
    print(r.status_code)
    print(r.text)
def wallet():
    r = requests.get(ip+'/wallet', headers=headers)
    print(r.status_code)
    print(r.text)
def report_user_status():
    r = requests.post(ip+'/report/user_status', headers=headers)
    print(r.status_code)
    print(r.text)
#加金币函数
def test_add_user_coin():
    r = requests.post(ip+'/wallet/v2/add_coin', headers=headers, json={"coin_num": 10000000})
    print(r.status_code)
    print(r.text)

#增加体力
def test_add_user_hp():
    r = requests.post(ip+'/game/reset', headers=headers, json={"hp":15})
    print(r.status_code)
    print(r.text)

#增加主线关数
def test_add_user_checkpoint():
    r = requests.post(ip+'/game/reset', headers=headers, json={'checkpoint': 100})
    print(r.status_code)
    print(r.text)
test_add_user_checkpoint()

# 修改房子级别

def test_add_user_house_level():
    r = requests.post(ip+'/game/reset', headers=headers, json={'house_level': 10}) #房子级别从0开始
    print(r.status_code)
    print(r.text)

# 修改树级别

def test_add_user_tree_level():
    r = requests.post(ip+'/game/reset', headers=headers, json={'tree_level':5})
    print(r.status_code)
    print(r.text)

# 修改宠物级别

def test_add_user_pet_level():
    r = requests.post(ip+'/game/reset', headers=headers, json={'pet_level':10})
    print(r.status_code)
    print(r.text)

    r = requests.post
# 抽奖
def test_phone_lottery_reward():
    r = requests.post(ip + '/phone_lottery/reward', headers=headers, json={'lottery_type': 1})
    print(r.status_code)
    print(r.text)

# 手机碎片兑换成金币

def test_phone_lottery_exchange():
    r = requests.post(ip + '/phone_lottery/exchange', headers=headers)
    print(r.status_code)
    print(r.text)


#抽奖页面详情

def test_phone_lottery_info():
    r = requests.get(ip + '/phone_lottery/info', headers=headers)
    print(r.status_code)
    print(r.text)

#game_status
def game_status():
    r = requests.get(ip + '/game_status', headers=headers)
    print(r.status_code)
    print(r.text)
#循环
# def test_for():
#     for i in range(5):
#         # test_phone_lottery_reward()
#         test_adventure_challenge()


#签到

def test_check_in():
    r = requests.get(ip + '/v2/check_in', headers=headers)
    print(r.status_code)
    print(r.text)

# test_check_in()


# def test_v2_check_in():

def test_adventure_challenge():
    r = requests.post(ip + '/adventure/challenge',headers=headers)
    print(r.status_code)
    print(r.text)






#看图猜成语
def test_game_guess_end():
    r = requests.post(ip+'/game/guess_end', headers=headers, json={'passed_checkpoint': 6})
    print(r.status_code)
    print(r.text)
    a = r.json()
    event_id = a.get('data').get('event_id')
    print(a.get('data').get('event_id'))
    if event_id is not None:
        r = requests.post(ip + '/game/guess_ad_reward', headers=headers, json={"event_id": event_id})
        print(r.status_code)
        print(r.text)

def test_game_guess_ad_reward():
    r = requests.post(ip+'/game/guess_ad_reward',headers=headers,json={"event_id":"1595907849NjXD"})
    print(r.status_code)
    print(r.text)

# 获取锦鲤发放信息
def test_koi_winners():
    r = requests.get(ip + '/koi/winners', headers=headers)
    print(r.status_code)
    print(r.text)

#锦鲤获奖名单
def test_koi_status():
    r = requests.get(ip + '/koi/status', headers=headers)
    print(r.status_code)
    print(r.text)


#用户锦鲤收集进度
def test_koi_process():
    r = requests.get(ip + '/koi/process',headers=headers)
    print(r.status_code)
    print(r.text)

# 金币
def test_coin():
    r = requests.post(ip +'/v3/wallet/withdraws',headers=headers,json={"cash_num":1,"prize_num_cfg_index": 0, "prize_mode": 1 })
    print(r.status_code)
    print(r.text)




